package cn.itcast.service;

import cn.itcast.PermissionDao;
import cn.itcast.PermissionService;
import cn.itcast.pojo.PageResult;
import cn.itcast.pojo.Permission;
import cn.itcast.pojo.QueryPageBean;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = PermissionService.class)
@Transactional
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionDao permissionDao;
    @Override
    public PageResult findPage(QueryPageBean pageBean) {
        PageHelper.startPage(pageBean.getCurrentPage(),pageBean.getPageSize());
        Page<Permission> pagelist =permissionDao.findPage(pageBean.getQueryString());
        return new PageResult(pagelist.getTotal(),pagelist.getResult());


    }

    @Override
    public Permission findById(Integer permissionId) {
      Permission permission=  permissionDao.findById(permissionId);
      return permission;
    }
}
